package cn.ivicar.cloud.guice;

import javax.inject.Inject;

import org.codehaus.jackson.jaxrs.JacksonJsonProvider;
import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.jersey.server.ResourceConfig;
import org.jvnet.hk2.guice.bridge.api.GuiceBridge;
import org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge;

public class IvicarApplication extends ResourceConfig {
    @Inject
    public IvicarApplication(ServiceLocator serviceLocator) {
        // Set package to look for resources in
        packages("cn.ivicar.cloud.ws");

        //注册JSON转换器
        register(JacksonJsonProvider.class);

        System.out.println("Registering injectables...");

        GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);

        GuiceIntoHK2Bridge guiceBridge = serviceLocator.getService(GuiceIntoHK2Bridge.class);
        guiceBridge.bridgeGuiceInjector(IvicarGuice.injector);
    }
}
